# vim: ts=4:sw=4:syntax=perl

sub mm_form_modify_portal_populate {
my ($portal,$portal_title,$portal_filename,$portal_users,$portal_template,$portal_owners,$portal_voters,$portal_concur)=@_;

	# portal is the name of the portal, so get existing details for
	# initial population.
	my $pd;
	{
		my $pn=hex_to_string($portal);
		$pd=$::GRI_FRONTEND->get_portal_details($pn);
		if(defined($pd->{error})) {
			return html_error("Failed to load details of portal '$pn'.",1);
		}
	}
	if($portal_title eq "?portal_title - not defined?") {;
		$portal_title=$pd->{title};
		$portal_filename=$pd->{filename};
		$portal_users=join(",",@{$pd->{users}});
		$portal_owners=join(",",@{$pd->{owners}});
		$portal_voters=join(",",@{$pd->{voters}});
		$portal_concur=$pd->{concur_count};
		$portal_template=$pd->{template};
	} else {
		$portal_title=hex_to_string($portal_title);
		$portal_filename=hex_to_string($portal_filename);
		$portal_users=hex_to_string($portal_users);
		$portal_owners=hex_to_string($portal_owners);
		$portal_voters=hex_to_string($portal_voters);
		$portal_concur=hex_to_string($portal_concur);
		$portal_template=hex_to_string($portal_template);
	}

return "
        <INPUT TYPE=\"hidden\" VALUE=\"$portal_filename\" NAME=\"filename\" SIZE=\"60\" MAXLENGTH=\"40\">
    <tr class=gri_headerrow>
      <td class=gri_cell colspan=3>Existing Portal Details</td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell>&nbsp;</td>
      <td class=gri_cell>&nbsp;</td>
      <td class=gri_cell>&nbsp;</td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell align=left><font class=stdtextlarge>Title:</font></td>
      <td class=gri_cell>&nbsp;&nbsp;&nbsp;</td>
      <td class=gri_cell>
        <INPUT TYPE=\"text\" VALUE=\"$portal_title\" NAME=\"title\" SIZE=\"60\" MAXLENGTH=\"40\" TITLE=\"The name of the portal as shown in the front Intranet page.\">
      </td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell colspan=3>&nbsp;</td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell><font class=label><font class=stdtextlarge>Users:</font></td>
      <td class=gri_cell>&nbsp;&nbsp;&nbsp;</td>
      <td class=gri_cell>
        <INPUT TYPE=\"text\" VALUE=\"$portal_users\" NAME=\"users\" SIZE=\"60\" MAXLENGTH=\"40\" TITLE=\"A comma-separated list of users to allow access to portal. Can be altered later and left blank to make the portal public.\">
      </td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell colspan=3>&nbsp;</td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell><font class=label><font class=stdtextlarge>Owners:</font></td>
      <td class=gri_cell>&nbsp;&nbsp;&nbsp;</td>
      <td class=gri_cell>
        <INPUT TYPE=\"text\" VALUE=\"$portal_owners\" NAME=\"owners\" SIZE=\"60\" MAXLENGTH=\"250\" TITLE=\"A comma-separated list of users that can make changes to the portal. Can be left blank to allow only users with admin roles make changes.\">
      </td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell colspan=3>&nbsp;</td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell><font class=label><font class=stdtextlarge>Voters:</font></td>
      <td class=gri_cell>&nbsp;&nbsp;&nbsp;</td>
      <td class=gri_cell>
        <INPUT TYPE=\"text\" VALUE=\"$portal_voters\" NAME=\"voters\" SIZE=\"60\" MAXLENGTH=\"250\" TITLE=\"A comma-separated list of users that have voting rights on user requests to access this portal. Can be left blank to allow only users with admin roles make changes.\">
      </td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell colspan=3>&nbsp;</td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell><font class=label><font class=stdtextlarge>Concur Count:</font></td>
      <td class=gri_cell>&nbsp;&nbsp;&nbsp;</td>
      <td class=gri_cell>
        <INPUT TYPE=\"text\" VALUE=\"$portal_concur\" NAME=\"concur\" SIZE=\"60\" MAXLENGTH=\"250\" TITLE=\"The number of voters that must agree for access to be granted for a particular user request. Can be left blank to allow only users with admin roles make changes.\">
      </td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell colspan=3>&nbsp;</td>
    </tr>
    <tr class=gri_row>
      <td class=gri_cell><font class=label><font class=stdtextlarge>Template:</font></td>
      <td class=gri_cell>&nbsp;&nbsp;&nbsp;</td>
      <td class=gri_cell>
        <INPUT TYPE=\"text\" VALUE=\"$portal_template\" NAME=\"template\" SIZE=\"60\" MAXLENGTH=\"80\" TITLE=\"The name of a file containing information to customise the look of the portal.\">
      </td>
    </tr>\n";
}

1;

